<template>
	<view class="personStatus">
		<view class="personal_jkhz_bg">
			<image src="@/static/images/index/personal_jkhz.png" mode="" style="width: 100%;" @click="enterMyright"></image>
			<view v-if="status==0" class="status">已激活</view>
			<view v-else-if="status==1" class="status">已失效</view>
			<view class="positionbotom">
				<text>权益人：{{from.activatedBy || from.name}}</text> 
				<text style="float: right;">有效期至：{{from.expiryDate || numbersss}}</text>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data(){
			return{
				status:0,
				from: {},
				numbersss:""
			}
		},
		onLoad: function(option) {
		  console.log(option,'option')
		  this.from = JSON.parse(option.data)
		  console.log(JSON.parse(option.data),'this.form?.activationCodes?.activationTime')
		  if(JSON.parse(option.data)?.activationCodes?.activationTime){
			this.numbersss =  this.getSimpleDate(this.addDays(JSON.parse(option.data).activationCodes.activationTime, Number(JSON.parse(option.data).activationCodes.expiryDate)))
			console.log(this.numbersss,'csnihiehfh')
		  }
		},
		methods: {
			enterMyright(){
				uni.navigateTo({
					url: `/pages/code/myRights?data=${JSON.stringify(this.from)}`
				});
			},
			
			addDays(date, days) {
				var result = new Date(date);
				result.setDate(result.getDate() + days);
				return result;
			},
			// 中国标准时间 转换成 年月日
			getSimpleDate(date) {
				var y = date.getFullYear();
				var m = date.getMonth() + 1;
				m = m < 10 ? ('0' + m) : m;
				var d = date.getDate();
				d = d < 10 ? ('0' + d) : d;
				var h = date.getHours();
				var minute = date.getMinutes();
				minute = minute < 10 ? ('0' + minute) : minute;
				var s = date.getSeconds();
				s = s < 10 ? '0' + s : s;
				return y + '-' + m + '-' + d
			}
			
		}
	}
</script>

<style>
	.personStatus{
		padding: 40rpx;
	}
	.personal_jkhz_bg{
		position: relative;
	}
	.status {
	    position: absolute;
	    left: 0rpx;
	    top: 0rpx;
	    font-size: 26rpx;
	    color: rgb(255, 255, 255);
	    background: rgb(50, 185, 188);
	    padding: 10rpx 20rpx;
	    border-radius: 20rpx 0rpx 30rpx;
	}
	.positionbotom{
		position: absolute;
		left: 20rpx;
		bottom: 20rpx;
		font-size: 30rpx;
		color: rgb(153, 153, 153);
		width:94%;
	}
</style>